package com.javasea.web.httpclient.retrofit;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

/**
 *@ClassName RetrofitDemo
 *@Description TODO
 *@Author longxiaonan@163.com
 *@Date 2020/12/19 0019 17:10
 */
@RestController
public class RetrofitDemoController {

    @Autowired
    private RetrofitHttpApi retrofitHttpApi;

    /**
     * http://localhost:8008/testRetrofit
     * @return
     */
    @GetMapping("/testRetrofit")
    public Map<String, Object> test(){
        return retrofitHttpApi.getAreas(1L);
    }

    /**
     * http://localhost:8008/testException
     * @return
     */
    @GetMapping("/testException")
    public Map<String, Object> test2(){
        try {
            retrofitHttpApi.testException();
        } catch (Exception e) {
            System.out.println("222>>>>" + e.getMessage());
        }
        return null;
    }

    @GetMapping("/testException2")
    public Map<String, Object> test3(){
        int  i = 1/0;
        return null;
    }


}
